# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=desktop-file-utils
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.26
pkgrel=1
arch=('any')
pkgdesc="Utilities for .desktop files (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-libxml2")
makedepends=("gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=('!strip' 'debug' 'staticlibs')
license=("LGPL 2.1")
url="https://www.gnome.org/"
source=(https://www.freedesktop.org/software/${_realname}/releases/desktop-file-utils-${pkgver}.tar.xz
        001-win.patch)
sha256sums=('b26dbde79ea72c8c84fb7f9d870ffd857381d049a86d25e0038c4cef4c747309'
            '477686cf08eaf80f5ee7f474cd6fb67361539f625c88fb9483ce600c5c8a73df')

prepare() {
  cd ${_realname}-${pkgver}

  patch -b -V simple -p1 -i ${srcdir}/001-win.patch

  autoreconf -fi
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib
  make
}

package() {
  cd "$srcdir/build-${MINGW_CHOST}"
  make DESTDIR=$pkgdir install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
